package com.itnoob.clone;

/**
 * @author zhoujun
 * @date 2025/3/21 22:53
 */
public class Main {
    public static void main(String[] args) throws CloneNotSupportedException {

        File f1 = new File("f1.txt");
        File f2 = new File("f2.doc");
        File f3 = new File("f3.jpg");
        Folder fo1 = new Folder("fo1");
        Folder fo2 = new Folder("fo2");
        Folder fo3 = new Folder("fo3");

        fo1.add(f1);
        fo1.add(fo2);
        fo2.add(f2);
        fo2.add(fo3);
        fo3.add(f3);

        fo1.disPlay();
        System.out.println("fo1:" + fo1 + ",address " + System.identityHashCode(fo1));

        //调用根节点fo1的clone方法,复制整个树形结构,并赋值给新的fo4
        Folder fo4 = (Folder)fo1.clone();
        fo4.disPlay();
        System.out.println("fo4:" + fo1 + ",address " + System.identityHashCode(fo1));

    }
}
